package com.leetcode.partition9;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2021/12/27 11:58
 */
public class LC825适龄的朋友 {
    
    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int[] ages = new int[s.length];
        for (int i = 0; i < s.length; i++) ages[i] = Integer.parseInt(s[i]);
        writer.write(numFriendRequests(ages) + "\n");
        writer.flush();
    }

    public static int numFriendRequests(int[] ages) {
        Arrays.sort(ages);
        int answer = 0;
        for (int i = 0, left = 0, right = 0; i < ages.length; i++) {
            //14以下的不会发送任何请求
            if (ages[i] <= 14) continue;
            while (ages[left] <= 0.5 * ages[i] + 7) left++;
            while (right + 1 < ages.length && ages[right + 1] <= ages[i]) right++;
            answer += right - left;
        }
        return answer;
    }
}
